Repository navigation
Feat(publish): Gate workflow edits behind a switch - #188
ModeSevenIndustrialSolutions merged 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The gate can incorrectly reject README-only revisions due to inherited reverted workflow changes and redundantly repeats network fetches and diffs for every workflow path.
2 open issues
What changed in this PR
Adds an off-by-default operator switch for workflow edits in new bot proposals, addressing #143. The trusted publisher also limits revision rounds to workflow files already changed by their pull request.
Changes:
- Passes
allow_workflow_editsthrough workflow callers into trusted selection evidence. - Adds publisher checks for new proposals and revision workflow paths.
- Updates agent prompts, documentation, and tests for the new rules.
| File | Description |
|---|---|
tests/test_workflow.py |
Pins switch defaults, forwarding, and prompt context. |
tests/test_workflow_gate.py |
Tests proposal permissions and revision workflow restrictions. |
tests/test_select_issues.py |
Checks selection records the switch. |
tests/test_proposal_check.py |
Updates fixtures and existing workflow-edit tests. |
scripts/workflow_gate.py |
Implements workflow-path authorization checks. |
scripts/selection_inputs.py |
Adds the selection command-line flag. |
scripts/selection_document.py |
Records the switch in selection evidence. |
scripts/proposal_model.py |
Tracks the PR’s original base and permission context. |
scripts/proposal_check.py |
Applies the gate using the trusted selection value. |
README.md |
Summarizes workflow-edit restrictions. |
prompt/revise.md |
Defines revision workflow-file limits. |
prompt/author.md |
Requires abstention when workflow edits are disabled. |
docs/DESIGN.md |
Documents the switch and publisher enforcement. |
.github/workflows/testing.yaml |
Forwards the manual switch and disables it for plumbing. |
.github/workflows/code-monkey.yaml |
Declares the input and passes it to selection and prompt context. |
.github/workflows/code-monkey-cron.yaml |
Exposes and forwards the switch, defaulting off. |
Review effort: Balanced
2de149d to
f5fbd7e
Compare
f5fbd7e to
16c5f69
Compare
16c5f69 to
ccee88b
Compare
Add expected-fail tests for issue lfreleng-actions#143. A new proposal that adds, edits or deletes a file under .github/workflows/ is rejected, naming the file, unless the trusted selection sets allow_workflow_edits to true; a selection without the field keeps it off. A revision round may change only the workflow files its pull request already changes, whatever the switch says, and upstream workflow changes a rebase brings in do not count against it. A round carrying over the pull request's own workflow commits, such as an edit and its revert, passes when it leaves those files as its base had them and writes nothing to them the published commits did not; the check reads the pull request's diff once however many workflow paths a round names. Carried-over changes must match the published ones in order and no more often, so a round repeating an edit and its revert is rejected; a rebase over an upstream edit elsewhere in the same workflow file still passes, since the carried edit makes the same line change. Changes are compared as raw bytes, split at LF alone: a rewritten edit whose bytes are not UTF-8, or hold another line separator, must not read the same as the published one (Copilot review round 3). A carried change must also sit where the published one did: the same edit and revert of a line repeated in another job is rejected, while the published job's own pair passes. A workflow name holding a glob character covers that file alone, so changing a sibling workflow the glob would match in the same commit leaves the carried change intact (Copilot review round 4). The contract tests expect the reusable workflow's input, off by default, its record in selection.json, a runtime context line for the agent, the prompt rules, and both dispatch callers forwarding it. The existing tests that propose a workflow change now turn the switch on. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
A new proposal could change any file under .github/workflows/, the change with the widest reach the bot makes. Put it behind an operator switch, allow_workflow_edits, off by default. The reusable workflow takes the input and the select step records it in selection.json, which the publisher trusts. The offline check (workflow_gate.py) rejects a new proposal that adds, edits or deletes a workflow file unless the switch is on, naming the file; a selection without the field counts as off. A revision round may change the workflow files its pull request already changes and no other, whatever the switch says: the check fetches the pull request's recorded base and published head from the bot fork and compares the round's workflow paths with that diff, computed once for all of them. A chain that touches no workflow file fetches nothing. A round keeps the pull request's commits, so it can carry a workflow edit and its revert that the net diff no longer shows. Such a path passes when the chain leaves it as its base had it and the published commits, read along the first-parent line for at most 64 commits, already made each change the chain makes to it, in the same order and no more often. A change is the file's mode and blob before and after a commit, read from its raw diff with no pathspec. The published changes are replayed onto the chain's base, each merged three ways as a rebase would, so a rebase over an upstream edit elsewhere in the file still matches; a new, moved, rewritten or repeated change is rejected. Review round 1 (Copilot): the check rejected a readme-only round that preserved an inherited workflow edit and revert; it now recognises carried-over writes, with regression tests. The allowed path set was fetched and diffed once per workflow path inside a comprehension; it is now computed once. Review round 2 (Copilot): the carried writes were compared as an unordered set of blobs, which let a round replay a published edit and revert a second time, and rejected a rebased edit and revert whose blobs an upstream edit to the same file had changed. Compare each path's line changes in order instead, with regression tests for both. Review round 3 (Copilot): the carried changes were read through UTF-8 replacement decoding and split at every Unicode line break, so a rewritten edit with other non-UTF-8 bytes, or a carriage return in place of a line feed, read the same as the published one. Read the patches as bytes and split them at LF alone, with regression tests for both. Review round 4 (Copilot): with hunk positions dropped, a published edit and revert of a line in one job matched a rewritten pair making the same edit in another job. The per-path patch also took the path as a pathspec, so a workflow name holding a glob character pulled in a sibling file's changes. Compare exact mode and blob transitions from each commit's raw diff, with the published ones replayed onto the chain's base by git merge-file, with regression tests for both. This also covers round 3's byte-level concerns. The author prompt's runtime context states the switch for an issue session, and both prompts carry the rule. The cron and testing callers offer the input on their dispatch forms, off by default, and forward it; the plumbing job passes false. Update DESIGN.md sections 8, 9, 10.1, 14, 17, 18 and 20.3 and the README. Fixes lfreleng-actions#143 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
ccee88b to
e1a6d3b
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Publication authorization now relies on shallow-history reconstruction and three-way replay of workflow edits, requiring maintainer review of the security semantics and Git compatibility validation on the publish runner.
No open issues 🎉
Review effort: Balanced
There was a problem hiding this comment.
🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.
The change appears sound: the default-off switch reaches the publisher through trusted selection data, and revision permissions derive from the published pull request rather than agent output. No actionable defects found in the diff and surrounding code.
Antagonistic round 1 of 3.
Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.
7768188
into
lfreleng-actions:main


Closes #143
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLId5881c29034245057f5c480b75ca36b905790df8uv run python -B -m unittest tests.test_workflow_gate (new tests on the old code: 2 failures, both findings reproduced)uv run python -B -m unittest discover -s tests (head)uv run python -B -m unittest discover -s tests (test commit)prek run --files scripts/workflow_gate.py tests/test_workflow_gate.py docs/DESIGN.mduvx zizmor --persona auditor .github/workflows/git log --raw --format=%h d5881c29034245057f5c480b75ca36b905790df8..HEAD (no 100755/120000/160000, no mode change)The
github-code-monkey-botworkflow opened this pull request.Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.
Round 4 of revision, on its base.
Closes #143.
What this pull request does
allow_workflow_edits, is off by default and recorded inselection.json. While it is off, the publisher rejects a new proposal that adds, edits or deletes a file under.github/workflows/. The rejection reason names the file, and the author prompt tells the agent to abstain in that case. The cron and testing callers forward the input.scripts/workflow_gate.py), never from agent output or review text. Upstream workflow changes that a rebase brings in do not count against the round.docs/DESIGN.md(§8, §9, §10.1, §14, §17, §18, §20.3), both prompts and the README are updated.This round (Copilot review round 4)
contents: readin one job matched the same pair in another job. The gate now compares the exact mode and blob of each path before and after each commit. The published changes are replayed onto the chain's base withgit merge-file --object-id --diff-algorithm=histogram, so a change has to sit where the published one did. A rebase over an upstream edit elsewhere in the file still matches.ci*.yamlalso picked upci-other.yaml. Transitions now come from each commit'sdiff-tree --rawoutput with no pathspec at all.Checks run
uv run python -B -m unittest discover -s tests: 1494 tests, OK at the head; OK with 33 expected failures at the test commit.prek run --fileson the changed files, including the aislop gate, basedpyright and mypy: passed.uvx zizmor --persona auditor .github/workflows/: no findings.For the reviewer
merge-file --object-idand--diff-algorithm. If the merge fails for any reason, replay stops, which only rejects more.d5881c2.